<template>
    <div>
        <el-cascader v-model="stateInput" :options="options" style="width: 100%" v-if="inventoryFormId"
                     :disabled="true"></el-cascader>
        <el-cascader v-model="stateInput" :options="options" style="width: 100%" v-else></el-cascader>
    </div>
</template>

<script>
export default {
    props: {
        inventoryFormId: {
            type: Number
        },
        value: {
            type: Array,
            default() {
                return []
            }
        },
    },
    computed: {
        stateInput: {
            get() {  // 编辑时-接受数据
                return this.value
            },
            set(newV) { // 选择-数据
                this.$emit('input', newV)
            }
        }
    },
    data() {
        return {
            options: [
                {
                    value: '01',
                    label: '饲料',
                    children: [
                        {
                            value: '0101',
                            label: '奶粉料(0101)',
                        },
                        {
                            value: '0102',
                            label: '保育料(0102)',
                        },
                        {
                            value: '0103',
                            label: '育肥料(0103)',
                        },
                        {
                            value: '0104',
                            label: '后备料(0104)',
                        },
                        {
                            value: '0105',
                            label: '妊娠料(0105)',
                        },
                        {
                            value: '0106',
                            label: '哺乳料(0106)',
                        },
                    ],
                },
                {
                    value: '02',
                    label: '兽药',
                    children: [
                        {
                            value: '0201',
                            label: '针剂(0201)',
                        },
                        {
                            value: '0202',
                            label: '粉剂(0202)',
                        },
                        {
                            value: '0203',
                            label: '疫苗(0203)',
                        },
                        {
                            value: '0204',
                            label: '激素(0204)',
                        },
                    ]
                },
                {
                    value: '03',
                    label: '器械设备',
                    children: [
                        {
                            value: '0301',
                            label: '辅助器械(0301)',
                        },
                        {
                            value: '0302',
                            label: '辅助设备(0302)',
                        },
                        {
                            value: '0303',
                            label: '辅助耗材(0303)',
                        },
                    ]
                },
                {
                    value: '04',
                    label: '精液(04)',
                },
                {
                    value: '05',
                    label: '消毒药(05)',
                },
                {
                    value: '06',
                    label: '实验室耗材(06)',
                },
                {
                    value: '07',
                    label: '燃料(07)',
                },
                {
                    value: '08',
                    label: '后勤类(08)',
                },
                {
                    value: '09',
                    label: '劳保福利',
                    children: [
                        {
                            value: '0901',
                            label: '服装类(0901)',
                        },
                        {
                            value: '0902',
                            label: '家纺类(0902)',
                        },
                        {
                            value: '0903',
                            label: '洗化类(0903)',
                        },
                        {
                            value: '0904',
                            label: '员工药品(0904)',
                        },
                    ]
                },
                {
                    value: '10',
                    label: '维修类',
                    children: [
                        {
                            value: '1001',
                            label: '维修配套(1001)',
                        },
                        {
                            value: '1002',
                            label: '建材类(1002)',
                        },
                        {
                            value: '1003',
                            label: '电路(1003)',
                        },
                        {
                            value: '1004',
                            label: '水路(1004)',
                        },
                    ]
                },
                {
                    value: '11',
                    label: '伙食类(11)'
                },
                {
                    value: '12',
                    label: '招待物资(12)'
                },
                {
                    value: '13',
                    label: '其他(13)'
                }
            ]
        }
    }
}
</script>